local skel = fk.CreateSkill {
  name = "rmt_hongdang__lianpian",
  tags = { Skill.Permanent, Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["rmt_hongdang__lianpian"] = "连篇",
  [":rmt_hongdang__lianpian"] = "持恒技，锁定技，当你使用锦囊牌指定其他角色为目标后，其隐匿；若其已隐匿，改为其横置；若其已横置，"..
  "改为其依次翻面、重置、登场。",

  ["$rmt_hongdang__lianpian"] = "年光似鸟翩翩过，世事如棋局局新。",
}

local DIY = require "packages.diy_utility.diy_utility"

local U = require "packages.utility.utility"

skel:addEffect(fk.TargetSpecified, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and
      data.card.type == Card.TypeTrick and data.firstTarget and
      table.find(data.use.tos, function(p)
        return p ~= player and not p.dead
      end)
  end,
  on_use = function(self, event, target, player, data)
    for _, p in ipairs(data.use.tos) do
      if p ~= player then
        if p.dead then
        elseif p:getMark("__hidden_general") == 0 and p:getMark("__hidden_deputy") == 0 then
          DIY.enterHidden(p)
        elseif not p.chained then
          p:setChainState(true)
        else
          p:turnOver()
          if not p.dead and p.chained then
            p:setChainState(false)
          end
          if not p.dead then
            if p:getMark("__hidden_general") ~= 0 or p:getMark("__hidden_deputy") ~= 0 then
              U.GeneralAppear(player, skel.name)
            end
          end
        end
      end
    end
  end,
})

return skel
